package zym.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sound.midi.Transmitter;
import zym.service.TansferMag;
import util.Page;

public class showLeave extends HttpServlet {


	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		this.doPost(request, response);
	}


	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		int pageNo=1;
		int pageSize=5;
		Page page=null;
		TansferMag tf=new TansferMag();
		try{
			if(request.getParameter("pageNo")!=null)
			{
				pageNo=Integer.parseInt(request.getParameter("pageNo"));
			}
			if(request.getParameter("pageSize")!=null)
			{
				pageSize=Integer.parseInt(request.getParameter("pageSize"));
				request.getSession().setAttribute("pageSize", pageSize);
			}
			if(request.getSession().getAttribute("pageSize")!=null)
			{
				pageSize=(Integer) request.getSession().getAttribute("pageSize");
			}
		}catch(Exception e)
		{
			e.printStackTrace();
		}
		if(null!=request.getParameter("keycode")&&!"".equals(request.getParameter("keycode")))
		
		{
			page=tf.getLeaveByType(pageNo,pageSize,Integer.parseInt(request.getParameter("keycode")));
		}else
		{
		page=tf.getAllLeave(pageNo,pageSize);
		}
		request.setAttribute("page", page);
		
		request.getRequestDispatcher("/Transfer/show_leave.jsp").forward(request, response);
	}

}
